//字典颜色渲染器
function BasicDicColorRender_main() {
    return {
        dClick: function (cmp, r) {
            BasicDicColorRender_form().view({
                entityId: r.get('id')
            });
        },
        id: 'BasicDicColorRender_main',
        xtype: 'jgrid',
        clazz: BasicDicColorRender,
        order: [],
        where: [],
        top: [$.color('red', '本工具只对字典有效!'), {
            name: 'dicKey',
            xtype: 'textfield',
            op: 'like'
        }, $.search, '->', {
            key: 'A',
            iconCls: ion.add,
            text: '添加',
            handler: function () {
                BasicDicColorRender_form().save({
                    grid: ['BasicDicColorRender_main']
                });
            }
        }, {
            key: 'E',
            iconCls: ion.edit,
            text: '修改',
            handler: function () {
                BasicDicColorRender_form().edit({
                    grid: ['BasicDicColorRender_main']
                });
            }
        }, {
            key: 'D',
            iconCls: ion.del,
            text: '删除',
            handler: function () {
                $('BasicDicColorRender_main').deletes({
                    validate: []
                });
            }
        }],
        columns: [
            {
                "name": "dicKey",
                width: 200
            },
            {
                flex: 1,
                "name": "color",
                renderer : function (value){
                    return Ext.String.format('<span style="background-color:#{0}">{1}</span>&nbsp;&nbsp;#{2}',value,"&nbsp;".times(30),value)
                }
            }
        ]
    }
}

function BasicDicColorRender_form() {
    return $({
        xtype: 'jform',
        clazz: BasicDicColorRender,
        fieldsSize: 1,
        hides: [],
        validate: [['dicKey = ?', 'dicKey', '已存在的关键字!']],
        fields: [
            {
                req: true,
                "name": "dicKey"
            },
            {
                xtype: 'colorpicker',
                // value: '#993300',
                listeners : {
                    select: function (cmp, value) {
                        if(value){
                            cmp.up("jform").set("color",value);
                        }
                    }
                }
            },
            {
                "name": "color"
            }
        ]
    })
}